package com.cskaoyan.dbutils;

import com.cskaoyan.dbutils.resultsetHandler.MyResultSetHandler;
import com.cskaoyan.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.HashMap;

/**
 * 创建日期: 2022/11/18 17:15
 *
 * @author ciggar
 */
public class QueryRunnerDemo2 {

    public static void main(String[] args) throws SQLException {

        // 1. 创建一个QueryRunner
        DataSource dataSource = DruidUtils.getDataSource();
        QueryRunner queryRunner = new QueryRunner(dataSource);


        // 2. 执行一个查询语句
        HashMap<String,Object> hashMap = (HashMap<String, Object>) queryRunner.query("select * from account where id = ?", new MyResultSetHandler(), 1001);


        System.out.println("hashMap:" + hashMap);
    }
}
